package org.phantom.securityframework.datapermission.internal;

import org.phantom.securityframework.datapermission.QueryParameters;
import org.springframework.stereotype.Service;


/**
 * 计算oracle分页参数
 * @author apple
 *
 */
@Service("dimensionQueryCreatorOracleImpl")
public class DimensionQueryCreatorOracleImpl extends DimensionQueryCreatorDefaultImpl {

	@Override
	protected QueryParameters resolveQueryParameters(Object[] args) {
		QueryParameters p = super.resolveQueryParameters(args);
		int lt = p.getPage()*p.getRows()+1;
		int gt = (p.getPage()-1)*p.getRows();
		QueryParameters newInstance = new QueryParameters();
		newInstance.setPage(lt);
		newInstance.setRows(gt);
		newInstance.setOrder(p.getOrder());
		newInstance.setSort(p.getSort());
		return newInstance;
	}
}
